<?php

namespace app\admin\model\pt;

use think\Model;
use app\admin\model\pt\Person as PersonModel;


class Salary extends Model
{

    

    

    // 表名
    protected $name = 'pt_person_salary';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'salary_mode_text'
    ];
    

    
    public function getSalaryModeList()
    {
        return ['hour' => __('Salary_mode hour'), 'day' => __('Salary_mode day'), 'stage' => __('Salary_mode stage')];
    }


    public function getSalaryModeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['salary_mode']) ? $data['salary_mode'] : '');
        $list = $this->getSalaryModeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function person()
    {
        return $this->belongsTo(PersonModel::class, 'pt_person_id', 'id')->setEagerlyType(1);;
    }


}
